package com.x.Part7_枚举类.enumTest1;

/**
 * ClassName: Season1Test
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.03.08 22:49
 */
public class Season1Test {
    public static void main(String[] args) {
        System.out.println(Season1.SUMMER.getClass());//Part7_枚举类.enumTest.Season1
        System.out.println(Season1.SUMMER.getClass().getSuperclass());//java.lang.Enum
        System.out.println(Season1.SUMMER.getClass().getSuperclass().getSuperclass());//java.lang.Object

        //Enum类中有一些方法可以调用
        //1、toString()
        System.out.println(Season1.SUMMER.toString());//默认返回对象名，重写后返回toString的内容

        //2、name()
        System.out.println(Season1.SUMMER.name());//默认返回对象名


        System.out.println("-------------------------------------------------");


        //3、静态方法values()
        //把所有枚举类的对象放入该枚举类类型的数组中
        Season1[] values = Season1.values();
        for (int i = 0; i < values.length; i++) {
             System.out.println(values[i]);
        }

        //4、valueOf(String objName)返回当前枚举类中名称为objName的对象
        String objName = "WINTER";
        Season1 temp = Season1.valueOf(objName);
        System.out.println(temp);

        System.out.println("-------------------------------------------------");


        Season1.SUMMER.getInfo();
        Season1.SPRING.getInfo();



    }
}
